﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DocGenerator
{
    public static class Validator
    {
        public static bool ValidateDecimal(ref decimal theDecimal, Control theTextControl, Control theLabel)
        {
            if (!string.IsNullOrEmpty(theTextControl.Text))
            {
                theTextControl.Text = theTextControl.Text.Replace('.', ',');

                if (Decimal.TryParse(theTextControl.Text, out theDecimal))
                {
                    theLabel.ForeColor = System.Drawing.Color.Black;
                    return true;
                }
            }
            theLabel.ForeColor = System.Drawing.Color.Red;
            return false;
        }

        public static bool ValidateName(Control theTextControl, Control theLabel)
        {
            if (!string.IsNullOrEmpty(theTextControl.Text))
            {
                theLabel.ForeColor = System.Drawing.Color.Black;
                return true;
            }
            else
            {
                theLabel.ForeColor = System.Drawing.Color.Red;
                return false;
            }

        }
    }
}
